package Interaddress;

import java.net.InetAddress;

public class Demo1 {
    public static void main(String[] args) {
        try {
            InetAddress ip1=InetAddress.getLocalHost();
            System.out.println("Local Host IP Address: "+ip1.getHostAddress());
            System.out.println("Local Host Name: "+ip1.getHostName());

            InetAddress ip2=InetAddress.getByName("www.baidu.com");
            System.out.println("IP Address of www.baidu.com: "+ip2.getHostAddress());
            System.out.println("Name of www.baidu.com: "+ip2.getHostName());


            System.out.println("Is www.baidu.com reachable? "+ip2.isReachable(5000));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
